export class SpecVertex {
  constructor(vertex) {
    this.vertex = vertex;
    this.quantity = vertex.length;
    this.init();
  }
  init() {
    this.vertexArray = Array.from({ length: this.quantity * this.quantity }, () => 0)
  }
  getVertexRow(id) {
    const pIndex = this.vertex.indexOf(id);
    const col = [];
    this.vertex.forEach((item, index) => {
      col.push(this.vertexArray[pIndex * this.quantity + index])
    })
    return col;
  }
  getJoinVertexs(id) {
    return this.getVertexRow(id).map((item, index) => (item ? this.vertex[index] : '')).filter(Boolean)
  }
  setJoinVertexs(id, sides) {
    const pIndex = this.vertex.indexOf(id);
    sides.forEach((item) => {
      const index = this.vertex.indexOf(item);
      this.vertexArray[pIndex * this.quantity + index] = 1;
    });
  }
}
